// index.js
const api = require("../../api/index")
const http = require("../../api/http")
const { baseURL } = require("../../utils/request")
Page({
  data: {
    imageList: [
      // '/add/bg.jpg', 
      // '/add/select.png'
      // 替换为你的图片路径
    ],
    bannerList:[],
    campList:[],
    url: 'http://127.0.0.1:8080',
    baseURL: baseURL
  },
  // 营地地图
  goCampingMap() {
    wx.navigateTo({
      url: '/pages/campMap/campMap'
    });
  },
  // 会员服务
  goGuide() {
    wx.navigateTo({
      url: '/pages/member/member'
    });
  },
  goonMessage() {
    wx.navigateTo({
      url: '/pages/message/message'
    });
  },
  // 页面详情
  goDetail(event) {
    console.log("event", event)
    let campId = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/campDetail/campDetail?campId=${campId}`,
    });
   
  },
   //获取首页banner 数据
  //  getBanner(){
  //   wx.request({
  //     url: 'http://localhost:8080/wechatt/banner/list',
  //     method:"GET",
  //     header:{

  //     },
  //     data:{
  //       state:1,
  //     },
  //     success:(res)=>{
  //       console.log(res.data.rows)
  //       this.setData({
  //         bannerList:res.data.rows
  //       })
  //     }
  //   })
  // },
  onShow() {
    this.getImageList();
    this.recommandCamp()
  },
  onLoad() {
    // imageListS
    // this.getBanner();
  },
   //首页推荐营地
   recommandCamp(){
    var query = {
      campName: this.data.campName,
      state: this.data.state,
    }
    http.campList(query).then((res) => {
      console.log(res, "res")
      const{ rows}=res;
      this.setData({campList:rows})
    })
  },
 
  getImageList() {
    console.log("getImageList")
    api.getBannerList().then((res)=>{
      console.log(res,"res")
      if(res.data && res.code===200){
        this.setData({
          imageList: res.data
        })
      }else{
        console.error('获取设施列表失败', res.data);
      }
    })

  }
})
